from flask_learn.ORM增删改查 import models
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine

engine = create_engine("mysql+pymysql://root:qaz3357375@127.0.0.1:3306/test?charset=utf8", max_overflow=5)
Session = sessionmaker(bind=engine)
session = Session()

# 修改
session.query(models.Classes).filter(models.Classes.id > 0).update({models.Classes.name: models.Classes.name + '099'},
                                                                   synchronize_session=False)

# synchronize_session='evaluate'执行计算
session.query(models.Classes).filter(models.Classes.id > 0).update({models.Classes.name: models.Classes.id + 1},
                                                                   synchronize_session='evaluate')
session.commit()
session.close()
